package com.custom.tab;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;

public class AbstractViewController {

	private AbstractTabRootManager tabRootManager;
	private Activity activity;
	private View mainView;

	public AbstractViewController(AbstractTabRootManager tabRootManager, int layoutId) {
		this.tabRootManager = tabRootManager;
		this.activity = tabRootManager.getActivity();
		mainView = tabRootManager.getLayoutInflater().inflate(layoutId, null,
				false);
	}

	public AbstractTabRootManager getTabRootManager() {
		return tabRootManager;
	}

	public Activity getActivity() {
		return activity;
	}

	public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
			String key) {
	}

	public void broadcastMessageReceived(String key, String message) {
	}

	public boolean onBackPressed() {
		return false;
	}
	public void finish() {
		try {
			getActivity().finish();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	public void onDestroy() {

	}

	public void pushViewController(
			AbstractViewController viewControllerInterface) {
		tabRootManager.pushViewController(viewControllerInterface);
	}

	public void pushViewControllerClearingAll(AbstractViewController viewControllerInterface){
		tabRootManager.pushViewControllerClearingAll(viewControllerInterface);
	}
	public void onResume() {
	}

	public View getView() {
		return mainView;
	}

	public void startActivityForResult(Intent intent, int requestCode) {
		tabRootManager.getActivity().startActivityForResult(intent, requestCode,this);
	}

	public SharedPreferences getSharedPreferences() {
		return tabRootManager.getSharedPreferences();
	}

	public String getString(int resId) {
		return activity.getString(resId);
	}

	public void onActivityResult(int requestCode, int resultCode, Intent data) {
	}

}
